﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ProjectClone.Dialog
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class Window1 : Window
    {
        /// <summary>
        /// 源解决方案路径
        /// </summary>
        public string SourceFullName { get; set; }
        /// <summary>
        /// 目标解决方案目录路径
        /// </summary>
        public string DestinationDirPath { get; set; }

        /// <summary>
        /// 目标解决方案名称
        /// </summary>
        public string DestinationName { get; set; }

        public Window1()
        {
            InitializeComponent();
        }

        private void ButtonCancle_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            SourceFullName = _source.Text;
            DestinationDirPath = _destinationDir.Text;
            DestinationName = _destinationName.Text;
            this.DialogResult = true;
        }

        private void ButtonSelectSource_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "解决方案文件 (*.sln)|*.sln"
            };
            var result = openFileDialog.ShowDialog();
            if (result == true)
            {
                this._source.Text = openFileDialog.FileName;
            }
        }

        private void ButtonSelectDestination_Click(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog m_Dialog = new FolderBrowserDialog();
            m_Dialog.RootFolder = Environment.SpecialFolder.MyComputer;
            DialogResult result = m_Dialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            string m_Dir = m_Dialog.SelectedPath.Trim();
            this._destinationDir.Text = m_Dir;
        }
    }
}
